home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************/
- /* */
- /* Program Name: Chassis */
- /* Version: 6.0 */
- /* */
- /* by: Charles A. Hoffman */
- /* */
- /* ASSIST Consulting - or - GTE Laboratories */
- /* 147 Vernon Street Mail Stop 24 */
- /* Norwood, MA 02062 40 Sylvan Road */
- /* Waltham, MA 02254 */
- /* */
- /* Phone: (617) 551-0185 Phone: (617) 466-2131 */
- /* */
- /* America Online: chuck01 Internet: chuck@gte.com */
- /* ( AOL Internet: chuck01@aol.com ) */
- /* */
- /************************************************************************************/
- /* */
- /* Copyright 1992 Charles A. Hoffman. */
- /* */
- /************************************************************************************/
- /* */
- /* You may incorporate this source code into your own non-commercial product, as */
- /* long as the notice, below, is included, and you declare and register your own */
- /* copyright. Permission to include this code in a commercial product is not */
- /* granted, and must be obtained in writing from the copyright owner, listed */
- /* above. If you change this source code, you may not continue to use the */
- /* copyrighted name "Chassis" but may use a different name on your application. */
- /* The notice, below, must still be included. */
- /* */
- /************************************************************************************/
- /* */
- /* This program contains material from a version of the sample program */
- /* "Chassis," and the application program "MacEden," which were originally */
- /* created and copyrighted by Charles A. Hoffman. */
- /* */
- /************************************************************************************/
- /* */
- /* Compiled with Symantec Corp. THINK C 6.0 for Macintosh */
- /* */
- /************************************************************************************/
- /* */
- /* 6.0.0 - Made compatable with THINK C 6.0, and downward compatable with 5.0.4. */
- /* 5.1.2 - Fix to enable running in 32-bit mode on Mac-IIci and above (credit to */
- /* Jim Ulrey, Paul Bennell, and Marcelino Bernardo is in myActionProc.c). */
- /* Fix for two small memory leaks. Change author's address. */
- /* 4.3.1 - Small fix to enable running on Mac Plus. Major changes to */
- /* print routines. Small fixes for cursor behavior. Changes to scrolling */
- /* in Help routines. */
- /* 4.2.2 - Minor bug fix for scrolling in myActionProc and HelpGetProc. */
- /* 4.2.1 - First public release. */
- /* */
- /************************************************************************************/
-
- #include "MyHeaders.h"
-
- /************************************************************************************/
- /* MAIN */
- /************************************************************************************/
- main()
- {
- MainRetCode = 0; /* initialize return code */
-
- myResRefNum = CurResFile(); /* Get own resource file number */
-
- versRecHandle = (struct versRec **) GetResource ('vers',1); /* get vers resrce */
- HLock ((Handle) versRecHandle);
- j = (short) (**versRecHandle).versChar[6];
- k = (short) (**versRecHandle).versChar[6+1+j]; /* k is length of long string */
- for (m = 0; m < k+2; m++)
- versLongStr[m] = (**versRecHandle).versChar[6+j+1+m];
- HUnlock ((Handle) versRecHandle);
- ReleaseResource ((Handle) versRecHandle);
-
- WorkRetCode = InitMac(); /* Start the managers */
-
- WorkRetCode = ColorCheck(); /* Set "useColor" global */
-
- UseResFile (initResRefNum);
- prRecHdl = (THPrint) (NewHandle (sizeof (TPrint))); /* get handle for print rec */
- PrintDefault (prRecHdl); /* initialize print rec */
- prPortPtr = (TPPrPort) (NewPtr (sizeof (TPrPort))); /* get ptr to prnt port */
-
- WorkRetCode = SetUpMenus(); /* set up the menus */
-
- /** WorkRetCode = ShowInfoDlog(128); /* display the "About" dialog */
-
- myDragRect = screenBits.bounds; /* Set the boundries... */
- InsetRect(&myDragRect,10,10); /* ...for dragging */
-
- for (j=0; j<windMax; j++) /* Indicate all entries in */
- windTbl[j].windPtr = 0; /* windTbl are not in use */
- SetPt (&nextTextPosit, 10,40); /* Set posit of first text wind */
-
- workRegionH = NewRgn(); /* get region for TE clikloop */
-
- WorkRetCode = MainGetProc(); /* put the main window up */
-
- myQuitFlag = 0; /* set flag for main event loop */
-
- WorkRetCode = FinderFilesProc(); /* process any files from finder */
-
- /************************** */
- /* Main Event Loop * */
- /************************** */
- while (myQuitFlag == 0) /* loop till quit */
- {
-
- GetMouse (&locMouse); /* where is the mouse? */
- gMouse = locMouse; /* convert to .. */
- LocalToGlobal(&gMouse); /* .. global coordinates */
- mouseWindPart = FindWindow (gMouse, &mouseWindPtr); /* get ptr & part */
- CursorSelect (mouseWindPtr, mouseWindPart, NIL); /* set cursor to match */
-
- SystemTask(); /* let system have some time */
-
- if (GetNextEvent(everyEvent, &myEvent) != nullEvent) /* if not nullEvent */
- {
- switch (myEvent.what)
- {
- case (activateEvt): /* activate or deactivate */
- WorkRetCode =
- WhichWindow((WindowPtr) myEvent.message, &windSub);
- if (WorkRetCode == 0)
- switch (windTbl[windSub].windRec.refCon)
- {
- case (ProcMain):
- WorkRetCode = MainWindowProc();
- break;
- case (ProcText):
- WorkRetCode = TextWindowProc();
- break;
- case (ProcHelp):
- WorkRetCode = HelpWindowProc();
- break;
- }
- break;
-
- case (mouseDown):
- WorkRetCode = MouseDownProc();
- break;
-
- case (mouseUp):
- break;
-
- case (diskEvt):
- if (HiWord(myEvent.message) != noErr) /* if MountVol had err */
- { /* then initialize disk */
- SysBeep(NIL); /* beep */
- SetPt (&workPoint,30,40); /* position */
- DIBadMount (workPoint, myEvent.message); /* initialize */
- }
- break;
-
- case (networkEvt):
- break;
-
- case (driverEvt):
- break;
-
- case (app1Evt):
- break;
-
- case (app2Evt):
- break;
-
- case (app3Evt):
- break;
-
- case (app4Evt):
- break;
-
- case (keyUp):
- break;
-
- case (keyDown):
- case (autoKey):
- WorkRetCode = KeyDownProc();
- break;
-
- case (updateEvt):
- WorkRetCode =
- WhichWindow((WindowPtr) myEvent.message, &windSub);
- if (WorkRetCode == 0)
- {
- BeginUpdate(windTbl[windSub].windPtr);
-
- switch (windTbl[windSub].windRec.refCon)
- {
- case (ProcMain):
- WorkRetCode = MainDrawProc();
- break;
- case (ProcText):
- WorkRetCode = TextDrawProc();
- break;
- case (ProcHelp):
- WorkRetCode = HelpDrawProc();
- break;
- }
-
- EndUpdate(windTbl[windSub].windPtr);
- }
- break;
- }
- }
- else
- {
- /************************************/
- /* null event */
- /* The system doesn't need our */
- /* attention, so give one loop to */
- /* the proc associated with the */
- /* front window. */
- /************************************/
- workWindowPtr = FrontWindow(); /* which is front (active) ? */
- WorkRetCode =
- WhichWindow(workWindowPtr, &k); /* match ptr to table */
- if (WorkRetCode == 0) /* if it's a good match */
- { /* then */
- windSub = k; /* set the subscrpt */
- switch (windTbl[windSub].windRec.refCon) /* window type */
- {
- case (ProcMain):
- WorkRetCode = MainWindowProc();
- break;
- case (ProcText):
- WorkRetCode = TextWindowProc();
- break;
- case (ProcHelp):
- WorkRetCode = HelpWindowProc();
- break;
- }
- }
- }
- }
- /************************** */
- /* End of Main Event Loop * */
- /************************** */
-
- WorkRetCode = MainCloseProc(); /* close main window */
-
- WorkRetCode = ShutMac(); /* Shutdown routines */
-
- return MainRetCode; /* ALL DONE !!! */
- }
- /************************************************************************************/
- /* InitMac */
- /* This function initializes the managers which will be used by this program. */
- /************************************************************************************/
- short InitMac(void)
- {
- short InitRetCode = 0; /* set the return code to good */
-
-
- MaxApplZone(); /* expand heap to max size */
- for (j=0; j<20; j++) /* get a bunch o' master pointers */
- MoreMasters();
-
- /************************************ */
- /* NOTE - don't change the order * */
- /* of these initialization routines* */
- /************************************ */
- InitGraf(&thePort); /* intiialize QuickDraw */
- InitFonts(); /* initialize Font Manager */
- InitWindows(); /* initialize Window Manager */
- FlushEvents(everyEvent,0); /* initialize Event Manager */
- InitMenus(); /* initialize Menu Manager */
- TEInit(); /* initialize TextEdit */
- InitDialogs(NIL); /* initialize Dialog Manager */
- PrOpen(); /* initialize Print Manager */
- InitCursor(); /* initialize Cursor to arrow */
-
- DILoad(); /* load the Disk Init package */
-
- /* Get resource file number after */
- initResRefNum = CurResFile(); /* these loads and initializations */
-
- return InitRetCode;
- }
-
- /************************************************************************************/
- /* ShutMac */
- /* This function does routines prior to program shutdown. */
- /************************************************************************************/
-
- short ShutMac(void)
- {
- short SMRetCode = 0; /* set the return code to good */
-
- PrClose(); /* close memory of Print Mgr */
- DIUnload(); /* delete disk init package */
- DisposeRgn(workRegionH); /* release region for TE redraw */
-
- return SMRetCode;
- }
-